//
//  ShuJiXiangQing_ViewController.m
//  iBook
//
//  Created by apple on 15/1/19.
//  Copyright (c) 2015年 wikiflyer. All rights reserved.
//

#import "ShuJiXiangQing_ViewController.h"

@interface ShuJiXiangQing_ViewController ()

@end

@implementation ShuJiXiangQing_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    [_myTableV setTableFooterView:view];
    [_myTableV setBackgroundColor:[UIColor whiteColor]];
    [self.view addSubview:_myTableV];
    
    _theCell2Height=130;
    
    [self goLine];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString * str1=@"123";
    ShuJiXiangQing_TableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:str1];
    if (!cell) {
        cell=[[ShuJiXiangQing_TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str1];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    if (_dicDatas.count>0) {
        if (indexPath.row==0) {
            NSLog(@"%@",[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"ath"]]);
            [cell initCell1theImage:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"pic"]] shuming:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"onm"]] zuozhe:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"ath"]] time:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"dtc"]] yeshu:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"pag"]] daxiao:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"siz"]] jiage:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"val"]]];
        }else if (indexPath.row==1){
            if (_theCell2Choose==0) {
                [cell initCell2:[NSString stringWithFormat:@"%@",[_dicDatas objectForKey:@"dsc"]]];
            }
        }
    }
    cell.delegate=self;
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        return 130;
    }else if(indexPath.row==1){
        NSLog(@"% - - d",_theCell2Height);
        return _theCell2Height;
    }else{
        return 130;
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - ShuJiXiangQing_TableViewCell_Detegate
-(void)ShuJiXiangQing_TableViewCell_Detegate:(ShuJiXiangQing_TableViewCell *)theCell theHeight:(int)theHeight indexPath:(NSIndexPath *)theIndexPath{
    _theCell2Height=theHeight;
    _theCell2Choose=1;
    [_myTableV reloadData];
}


#pragma mark - 数据请求(Json-Post)
-(void)goLine{
    NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
    [dic setObject:_strIDJieShou forKey:@"oid"];
    [self getInformationByURl:@"http://www.xdoc.cn/json/LoadOceanInfo.aspx?"andDictionary:dic];
}
-(void)getInformationByURl:(NSString *)url andDictionary:(NSDictionary *)yourDictionary{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain",@"text/html",nil];
    [manager GET:url parameters:yourDictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self initWithDataS:responseObject];
        //        [self.view.window showHUDWithText:@"" Type:ShowDismiss Enabled:YES];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error);
    }];
}
//数据处理
-(void)initWithDataS:(NSDictionary *)theDic{
    NSLog(@" - - - all = %@",theDic);
    _dicDatas=[[NSDictionary alloc] initWithDictionary:theDic];
    [_myTableV reloadData];
}



@end
